<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let num = Math.floor(Math.random() * 11)
        // alert(num)
        while (true) {
            let n = +prompt("请输入0-10你要猜的数字：")
            if (n >= 0 && n <11) {
                if (n < num) alert("数字太小")
                else if (n > num) alert("数字太大")
                else if (n === num) {
                    document.write(`猜对了，值是${num}`)
                    break
                }
            }
            else {
                alert("无效值")
            }
        }
    </script>
</body>

</html>